import request from '@/utils/request'

const baseURL = 'http://localhost:39203/carbon/data'
// const baseURL = 'http://116.204.103.224:39203/data'

// 查询测试列表
export function pageList(data) {
  return request({
    url: '/pageList',
    method: 'post',
    data: data,
    baseURL: baseURL
  })
}

export function listYearVaryMaterialOneTo12CO2(data) {
  return request({
    url: '/listYearVaryMaterialOneTo12CO2',
    method: 'get',
    params: data,
    baseURL: baseURL
  })
}

/**
 * 根据年月范围计算各阶段总碳排放量
 * @param data
 * @returns {AxiosPromise}
 */
export function queryStageMonthRangeCO2(data) {
  return request({
    url: '/stageMonthRangeCO2',
    method: 'get',
    params: data,
    baseURL: baseURL
  })
}

/**
 * 根据年月范围计算年总碳排放量
 * @param data
 * @returns {AxiosPromise}
 */
export function queryYearRangeTotalCO2(data) {
  return request({
    url: '/yearRangeTotalCO2',
    method: 'get',
    params: data,
    baseURL: baseURL
  })
}

export function getAllYears() {
  return request({
    url: '/years',
    method: 'get',
    baseURL: baseURL
  })
}

// 查询测试列表
export function getTotalCO2() {
  return request({
    url: '/totalCO2',
    method: 'get',
    baseURL: baseURL
  })
}

// 查询各生产阶段的CO2排放量
export function getStageTotalCO2() {
  return request({
    url: '/stageCO2',
    method: 'get',
    baseURL: baseURL
  })
}

// 查询指定年各生产阶段的CO2排放量
export function getYearStageTotalCO2(year) {
  return request({
    url: `/stageYearCO2/${year}`,
    method: 'get',
    baseURL: baseURL
  })
}

// 查询各生产阶段的CO2占比
export function getProportionStage() {
  return request({
    url: '/proportionStage',
    method: 'get',
    baseURL: baseURL
  })
}

// 查询所有生产阶段
export function listStage() {
  return request({
    url: '/listStage',
    method: 'get',
    baseURL: baseURL
  })
}

// 根据能源物质查询工序
export function queryProcessByEmissionOrigin(id) {
  return request({
    url: `/queryProcessByEmissionOrigin/${id}`,
    method: 'get',
    baseURL: baseURL
  })
}

// 查询所有工序碳排放
export function queryAllProcessEmissionOrigin(year) {
  return request({
    url: "/queryAllProcessEmissionOrigin",
    method: 'get',
    params: {year: year},
    baseURL: baseURL
  })
}

// 查询近一个月的碳排放量
export function queryEmissionMonth() {
  return request({
    url: "/queryEmissionMonth",
    method: 'get',
    baseURL: baseURL
  })
}

// 查询制定年碳排放总量
export function curYearEmission() {
  return request({
    url: "/curYearEmission",
    method: 'get',
    baseURL: baseURL
  })
}

//
export function query12MonthEmission() {
  return request({
    url: "/query12MonthEmission",
    method: 'get',
    baseURL: baseURL
  })
}
